/**
 * Copyright (C) 2011 The Android Open Source Project 
 * Emial : guoyil199@163.com
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */ 
package com.test.v7;

import android.annotation.SuppressLint;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.text.Html;
import android.view.Menu;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.example.app.R;


/**
 * @author Administrator
 * @Email guoyil199@163.com
 * @version V1.0
 * @Date 2015年4月3日 上午9:30:04
 * @Title <pre>todo</pre>
 * @Description <pre>todo</pre>
 */

public class MainAct extends ActionBarActivity{
	
	private FrameLayout contentParent;
	/* (non-Javadoc)
	 * @see android.support.v7.app.ActionBarActivity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
//		contentParent=new FrameLayout(this);
//		contentParent.setBackgroundColor(Color.WHITE);
//		contentParent.setLayoutParams(new FrameLayout.LayoutParams(-1,-1));
//		setContentView(contentParent);
//		
//		View view=getLayoutInflater().inflate(R.layout.activity_main, contentParent,false);
//		contentParent.addView(view,0);
//		
//		
////		View view=View.inflate(this, R.layout.activity_main, contentParent);
////		TextView tvMsg=new TextView(contentParent.getContext());
////		tvMsg.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT));
////		tvMsg.setTextColor(Color.WHITE);
////		tvMsg.setTextSize(18,TypedValue.COMPLEX_UNIT_SP);
////		tvMsg.setText("MainAct.................");
//		//ImageView iv = new ImageView(this);
//		//iv.setImageResource(R.drawable.ic_launcher);
//		//ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT)
//		
//		LoadingView load=new LoadingView(this);
//		load.setMessage("test");
//		load.show();
//		
//		contentParent.addView(load,1);
//		
//		
//		view.setVisibility(View.GONE);
		setContentView(R.layout.activity_test);
		TextView t=(TextView) findViewById(R.id.testId);
		String text=getString(R.string.regedit_input_code,"te");
		System.out.println(text);
		t.setText(Html.fromHtml(text));
		
		
//		LoadingView load=(LoadingView) findViewById(R.id.loading);
//		load.setOrientation(LinearLayout.VERTICAL);
//		load.setMessage();
//		ActionBar bar=getSupportActionBar();
		
		
		//AsyncTaskCompat
		
	/*	XmlResourceParser xml=null;
		try {
			xml = getResources().getAssets().openXmlResourceParser("activity_main.xml");
			LayoutInflater minfInflater=LayoutInflater.from(this);
			View v=minfInflater.inflate(xml, null);
			setContentView(v);
		} catch (IOException e) {
			e.printStackTrace();
		}*/
	}
	
	/* (non-Javadoc)
	 * @see android.app.Activity#onCreateOptionsMenu(android.view.Menu)
	 */
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		return super.onCreateOptionsMenu(menu);
	}
	
	/* (non-Javadoc)
	 * @see android.support.v7.app.ActionBarActivity#onMenuOpened(int, android.view.Menu)
	 */
	@Override
	public boolean onMenuOpened(int featureId, Menu menu) {
		// TODO Auto-generated method stub
		return super.onMenuOpened(featureId, menu);
	}
	
	private  AsyncTask<Integer, Void, String> gettask(){
		return  new AsyncTask<Integer, Void, String>(){
			@Override
			protected String doInBackground(Integer... params) {
				//if(isCancelled()) return null;
				try {
					Thread.sleep(5000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				if(params[0]==1){
					return "params-----1";
				}else if(params[0]==2){
					return "params------2";
				}
				return null;
			}
			
			/* (non-Javadoc)
			 * @see android.os.AsyncTask#onPostExecute(java.lang.Object)
			 */
			@Override
			protected void onPostExecute(String result) {
				System.out.println("result:"+result);
			}
		};
	}
	
	@SuppressLint("NewApi")
	public void onClick(View v){
		/*if(v.getId()==R.id.btn1){
			atask=gettask();
			atask.execute(1);
		}else if(v.getId()==R.id.btn2){
			atask=gettask();
			atask.executeOnExecutor(Executors.newCachedThreadPool(),2);//executeOnExecutor(2);
		}else if(v.getId()==R.id.btn3){
			atask=gettask();
			atask.execute(3);
		}else if(v.getId()==R.id.btn4){
			
			if (atask != null && atask.getStatus() != AsyncTask.Status.FINISHED)
				atask.cancel(true);
		}*/
	}
	
}
